//
//  HLHomeViewController.m
//  HanlinWeather
//
//  Created by 任翰林 on 2017/2/20.
//  Copyright © 2017年 任翰林. All rights reserved.
//

#import "HLHomeViewController.h"
#import <Masonry.h>
#import "HLHomeCollectionView.h"
#import "GaoDeMapViewController.h"
#import "VideoViewController.h"
@interface HLHomeViewController ()<UINavigationControllerDelegate>

@end

@implementation HLHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[UIApplication sharedApplication] isStatusBarHidden];
    self.navigationController.delegate = self;
//    self.view.backgroundColor = [UIColor lightGrayColor];
    
//    UIImageView * imageView = [[UIImageView alloc]init];
//    imageView.image = [UIImage imageNamed:@"Stars"];
//    [self.view addSubview:imageView];
//    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.edges.equalTo(@0);
//    }];
    
//    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
//    
//    [self.navigationController.navigationBar setTranslucent:true];
    
 
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    
    [self setUpUI];
}

- (void)setUpUI
{
    
    UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.minimumLineSpacing = 0;
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flowLayout.itemSize = CGSizeMake(KScreenWidth, self.view.bounds.size.height - 110);
    HLHomeCollectionView * homeCollection  = [[HLHomeCollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flowLayout];
    homeCollection.homeTablePushBlock = ^(NSInteger section , NSInteger row){
        
        NSLog(@"%ld组，%ld行",section,row);
        if (section == 0 && row == 0) {
            GaoDeMapViewController * gaodeVC = [GaoDeMapViewController new];
            [gaodeVC setHidesBottomBarWhenPushed:YES];
            [self.navigationController pushViewController:gaodeVC animated:YES];
            
        }else if (section == 0 && row == 1){
            VideoViewController *videoVC = [VideoViewController new];
            [videoVC setHidesBottomBarWhenPushed:YES];
            [self.navigationController pushViewController:videoVC animated:YES];
        }else if (section == 0 && row == 2){
            
        }else if (section == 1 && row == 0){
            
        }else if (section == 1 && row == 1){
            
        }else if (section == 1 && row == 2){
            
        }
    };
//    homeCollection.alpha = 0.5;
    [self.view addSubview:homeCollection];
    [homeCollection mas_makeConstraints:^(MASConstraintMaker *make) {
        
//        make.edges.equalTo(@0);
        make.top.equalTo(self.view).offset(0);
        make.left.equalTo(self.view).offset(0);
        make.right.equalTo(self.view).offset(0);
        make.bottom.equalTo(self.view).offset(15);
    }];
    

    [self maopao1];
    
}

- (void)maopao2{

    NSMutableArray * array = [NSMutableArray arrayWithObjects: @"1",@"8",@"2",@"7",@"2",@"5",@"9",nil];
    
    //选择
    
    for (int  i =0; i<[array count]-1; i++) {
        
        for (int j = i+1; j<[array count]; j++) {
            
            if ([array[i] intValue]>[array[j] intValue]) {
                
                //交换
                
                [array exchangeObjectAtIndex:i withObjectAtIndex:j];
                
            }
            
        }
        
    }
    
    NSLog(@"%@",array);
    
    
    
    
    
    NSMutableArray * array1 =[[NSMutableArray alloc]initWithObjects:@"zhige",@"saozi",@"bge",@"xiaolong",@"xiaomo",@"xiaomi", nil];
    
    //冒泡
    
    for (int i =0; i<[array1 count]-1; i++) {
        
        for (int j =0; j<[array1 count]-1-i; j++) {
            
            if(([array1[j] compare:array1[j+1]]) == NSOrderedDescending){
                
                //交换
                
                [array1 exchangeObjectAtIndex:j withObjectAtIndex:j+1];
                
                
                
            }
            
        }
        
    }
    
    
    
    NSLog(@"%@",array1);
    
}

- (void)maopao1{
    
    NSMutableArray * Marray = [NSMutableArray arrayWithObjects:@9,@7,@5,@3,@1,@2,@4,@6, nil];
    for (int i= 0; i <Marray.count; i++) {
        for (int j = 0; j < Marray.count - i - 1; j++) {
            if (Marray[j] > Marray[j+1]) {
                [Marray exchangeObjectAtIndex:j withObjectAtIndex:j+1];
            }
        }
    }
    
//    for (id A in Marray) {
//        NSLog(@"%@",A);
//    }
//    
    
    
    
    NSMutableArray * Marray1 = [NSMutableArray arrayWithObjects:@"liucaifeng",@"rendongsheng",@"liucairong",@"renhanlin",@"xijinping",@"pengliyuan", nil];
    for (int i= 0; i <Marray1.count; i++) {
        for (int j = 0; j < Marray1.count - i - 1; j++) {
            if ([Marray1[j] compare: Marray1[j+1]] == NSOrderedAscending) {
                [Marray1 exchangeObjectAtIndex:j withObjectAtIndex:j+1];
            }
        }
    }
    
    NSLog(@"%@",Marray1);
    
    
    
    
    
}






- (void)leftItemClick:(UIBarButtonItem *)sender
{
    HLLog(@"xxx");
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
